var h = document.documentElement.clientHeight;
$('.row-hook').css({height: h + 'px'});
$('.jyaq').css({height: h - $('.minH').height() - 125 + 'px'});
$.jeDate("#startDate",{
    format:"YYYY-MM-DD hh:mm:ss",
    isTime:true,
    festival: false,
    maxDate: $.nowDate({DD: "+0"})
})
var time = $.nowDate({DD: "+0"}).replace(/-| |:/g,'');
var userId = $('#userId').val() ? $('#userId').val() : '005626'
$('.ajbh-hoof').val('A' + userId + time);
window.onresize = function(){
    h = document.documentElement.clientHeight;
    $('.row-hook').css({height: h + 'px'});
    $('.jyaq').css({height: h - $('.minH').height() - 125 + 'px'});
}
//事件类别
$.ajax({
    type: 'get',
    url: baseUrls + 'dict/ajlx',
    headers:{
        userName: encodeURI($('#userName').val()),
        userId: $('#userId').val()
    },
    beforeSend: function(){
        $('.canvasLoading').show();
    },
    success: function(response){
        $('.canvasLoading').hide();
        if(response.responseCode == '1000'){
            if(response.content.length > 0){
                for(var i = 0; i< response.content.length; i++){
                    $('#ajlx').append('<option value="'+ response.content[i].code +'">'+ response.content[i].name +'</option>')
                }
                $('#ajlx').multiselect({
                    buttonText: function(options, select) {
                        if (options.length === 0) {
                            return '请选择';
                        }else{
                            return options.length + '选择项';
                        }
                    }
                });
            }
        } else{
            mark('事件类型获取失败');
        }
    },
    error: function(){
        $('.canvasLoading').hide();
        mark('事件类型获取失败');
    }
})
//小案类别
!function getAjlb(item){
    if($(item).val() != ''){
        $.ajax({
            type: 'get',
            url: baseUrls + 'dict/ajlb',
            headers:{
                userName: encodeURI($('#userName').val()),
                userId: $('#userId').val()
            },
            // data: {code: $(item).val()},
            beforeSend: function(){
                $('.canvasLoading').show();
            },
            success: function(response){
                $('.canvasLoading').hide();
                if(response.responseCode == '1000'){
                    if(response.content.length > 0){
                        for(var i = 0; i< response.content.length; i++){
                            $('#ajlb').append('<option value="'+ response.content[i].code +'">'+ response.content[i].name +'</option>')
                        }
                        $('#ajlb').multiselect({
                            buttonText: function(options, select) {
                                if (options.length === 0) {
                                    return '请选择';
                                }else{
                                    return options.length + '选择项';
                                }
                            }
                        });
                    }
                } else {
                    mark('小案类别获取失败');
                }
            },
            error:function(){
                $('.canvasLoading').hide();
            }
        })
    } else{
        $('#ajlb').html('');
        $('#ajlb').html('<option value="">请选择</option>');
    }
}()
function infoSubmit(){
    $('#mation').ajaxSubmit({
        type: 'post',
        url: baseUrls + 'case/add',
        headers:{
            userName: encodeURI($('#userName').val()),
            userId: $('#userId').val()
        },
        beforeSend: function(){
            $('#canvasLoading').show();
        },
        success: function(responses){
            $('#canvasLoading').hide();
            mark('事件录入成功');
            window.location.href = 'relation.html';
        },
        error: function(){
            $('#canvasLoading').hide();
            mark('服务器异常，请稍候再试！');
        }
    })
}
//提示框
function mark(item){
    $('.H3').html(item);
    $('.mark').fadeIn();
    setTimeout(function(){
        $('.mark').fadeOut();
    },1000)
}